package cst.neu.yuejian_31.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import cst.neu.yuejian_31.R;
import cst.neu.yuejian_31.bean.FeedBackBean;
import cst.neu.yuejian_31.iface.FeedBackListener;
import cst.neu.yuejian_31.model.FeedBackModel;

public class FeedbackActivity extends BaseActivity implements FeedBackListener,View.OnClickListener {
    private EditText ed_contant;
    private Button btn_feedback;
    private ImageView btn_return;
    private String userId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_feedback);
        initView();
        initData();
        initEvent();
    }

    private void initEvent() {
        btn_return.setOnClickListener(this);
        btn_feedback.setOnClickListener(this);
    }

    private void initView() {
        ed_contant= (EditText) findViewById(R.id.editText_feedback_contant);
        btn_feedback=(Button) findViewById(R.id.button_feedback);
        btn_return= (ImageView) findViewById(R.id.imageView_feedback_return);
    }
    private void initData() {
        userId=getUserId();


    }

    @Override
    public void onSuccess(FeedBackBean feedBackBean) {
        Toast.makeText(this, "提交反馈成功", Toast.LENGTH_SHORT).show();

    }

    @Override
    public void onFail(String msg) {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.button_feedback:
                feedback();
                break;
            case R.id.imageView_feedback_return:
                finish();
                break;
        }


    }

    private void feedback() {
        FeedBackModel feedbackmodel=new FeedBackModel();
        feedbackmodel.feedBack(userId,ed_contant.getText().toString(),this);
    }
}
